package org.itheima.game.org.tank.game.model

import org.itheima.game.org.tank.game.Config

/**
 * description ： 显示的视图，定义规范
 * author : chenmengjia
 * email : cmjsp1990@163.com
 * date : 2020/3/14 14:19
 */
interface View {
    //位置
    var x: Int
    var y: Int
    var width: Int
    var height: Int
    //宽高
    fun draw()

//    fun checkCollision(view: View): Boolean {
//        return false
//
//    }

    fun checkCollision(x1: Int, y1: Int, w1: Int, h1: Int, x2: Int, y2: Int, w2: Int, h2: Int): Boolean {

        return when {
            y2 + h2 <= y1 -> {
                false

            }
            y1 + h1 <= y2 -> {
                //下方不碰撞
                false
            }
            x2 + w2 <= x1 -> {
                false
            }

            else -> x1 + w1 > x2
        }
    }
}